package mcchristian;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Albums_Pic_Action extends ActionSupport implements ServletRequestAware, ServletResponseAware{

	private List<Albums> albumses = new ArrayList<Albums>();
	private String message;
	private HttpServletRequest request; 
	private HttpServletResponse response;
	
	public String execute() throws Exception  
    {   
		Map session = ActionContext.getContext().getSession();
		Pic_Function pic_function = new Pic_Function();
		String pic_folder = (String)request.getParameter("pic_folder");
		String pic_folder_path = (String)session.get("rootpath") + "albums" + "\\" + pic_folder;
		if ((String)session.get("rootpath") == null){
			return "INDEX";  
		}	
		albumses = pic_function.getAlbums_Pic(pic_folder_path, pic_folder);
		request.setAttribute("title", pic_folder);
        return SUCCESS;  
    }
	
	public void setServletRequest(HttpServletRequest request) { 
        this.request = request; 
    } 
	
	public void setServletResponse(HttpServletResponse res) {
        this.response=res;
    }
	
	public List<Albums> getAlbumses() {
		return albumses;
	}

	public void setAlbumses(List<Albums> albumses) {
		this.albumses = albumses;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}


